/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package suministros.ejb30.entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author Luis_Angel
 */
@Entity
@Table(name = "area_empresa")
@NamedQueries({
    @NamedQuery(name = "AreaEmpresa.findAll", query = "SELECT a FROM AreaEmpresa a"),
    @NamedQuery(name = "AreaEmpresa.findByCodArea", query = "SELECT a FROM AreaEmpresa a WHERE a.codArea = :codArea"),
    @NamedQuery(name = "AreaEmpresa.findByNomArea", query = "SELECT a FROM AreaEmpresa a WHERE a.nomArea = :nomArea")})
public class AreaEmpresa implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    @Column(name = "cod_area")
    private Integer codArea;
    @Column(name = "nom_area")
    private String nomArea;
    @OneToMany(mappedBy = "codArea")
    private List<Trabajador> trabajadorList;

    public AreaEmpresa() {
    }

    public AreaEmpresa(Integer codArea) {
        this.codArea = codArea;
    }

    public Integer getCodArea() {
        return codArea;
    }

    public void setCodArea(Integer codArea) {
        this.codArea = codArea;
    }

    public String getNomArea() {
        return nomArea;
    }

    public void setNomArea(String nomArea) {
        this.nomArea = nomArea;
    }

    public List<Trabajador> getTrabajadorList() {
        return trabajadorList;
    }

    public void setTrabajadorList(List<Trabajador> trabajadorList) {
        this.trabajadorList = trabajadorList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (codArea != null ? codArea.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof AreaEmpresa)) {
            return false;
        }
        AreaEmpresa other = (AreaEmpresa) object;
        if ((this.codArea == null && other.codArea != null) || (this.codArea != null && !this.codArea.equals(other.codArea))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return nomArea;
    }

}
